<?php
defined('_JEXEC') or die( 'Restricted access' );

class igcategoriesModeladd_edit_category extends igbaseModel
{
	protected $_data = null;
	protected $context = 'edit_category';

	function __construct()
	{
		parent::__construct();
	}

	function &getData()
	{
		if(!$this->_loadData())
		{
			$this->_initData();
		}

		return $this->_data;
	}

    function _loadData()
	{
		if (empty($this->_data))
		{
			$query = 'SELECT * FROM #__igallery WHERE id = '. (int)$this->_id;
			$this->_db->setQuery($query);
			$this->_data = $this->_db->loadObject();
			return (boolean) $this->_data;
		}
		return true;
	}

	function _initData()
	{
		if (empty($this->_data))
		{
			$category = new stdClass();
			$user =& JFactory::getUser();
			$configArray =& JComponentHelper::getParams('com_igallery');

			$category->id = null;
			$category->folder_ref = null;
			$category->ordering = null;
			$category->name = null;
			$category->alias = null;
			$category->folder = null;
			$category->profile = null;
			$category->parent = 0;
			$category->menu_image_filenane = null;
			$category->cache = null;
			$category->menu_description = null;
			$category->gallery_description = null;
			$category->user = $user->id;
			$category->published = 1;
			$category->moderate = 0;
			$this->_data					= $category;
			return (boolean) $this->_data;
		}
		return true;
	}
	
	function checkProfileExists()
	{
	    $query = 'SELECT id FROM #__igallery_profiles';
		$this->_db->setQuery($query);
		$this->_db->query();
		$numRows = $this->_db->getNumRows();
	    if($numRows == 0)
		{
		    return false;
		}
		
		return true;
	}
	
}